package com.example.hongyu.avtt.network;

import com.trello.rxlifecycle2.LifecycleTransformer;

import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Greenhouse
 * Created by zhoudan on 2018/2/6.
 * RxJava转换封装
 * Version 1.0
 * CopyRight 麦卡
 */

public class RxTransformer {

    public static <T> ObservableTransformer<T, T> transform(LifecycleTransformer<T> transformer) {
        return upstream -> upstream.subscribeOn(Schedulers.io()) //在子线程中进行Http访问
                .observeOn(AndroidSchedulers.mainThread()) //UI线程处理返回接口
                .compose(transformer);
    }

}
